/**      
 * @file		pointerArithmetic.cpp
 * @description		This example demonstrates pointer arithmetic.
 *			we can get to the next element in the array by
 *			adding 1 to the pointer.
 * @course		CSCI 123 Section 00000
 * @assignment 
 * @date		mm/dd/yyyy
 * @author		Brad Rippe (00000000) brippe@fullcoll.edu
 * @version		1.0
 */
#include <iostream>
using namespace std;

typedef char* CharPtr;

/**
 * @return zero if the application executes successfully
 */
int main() {
	
	CharPtr name = new char[100];

	cout << "Type the your name:\n";
	cin  >> name;
	cout << "Your name is " << name << endl;

	for (int i = 0; name[i] != '\0'; i++) {
		// if I add 1 to the pointer
		// I get the next char in the array
		// this works based on the type of array we're dealing with
		// If I add 2 to the pointer, I get the 3 element in the array
		cout << "name[" << i << "] " << *(name+i) << endl;
	}
	cout << endl;

	int i = 0;
	while (*name != '\0') {
		// if I add 1 to the pointer
		// I get the next char in the array
		// this works based on the type of array we're dealing with
		// If I add 2 to the pointer, I get the 3 element in the array
		cout << "name[" << i++ << "] " << *(name++) << endl;
	}
	cout << endl;

	return 0;
}
